<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <!-- 
        v-once指令：
            1.v-once指令所在的节点在初次动态渲染后，就视为静态的内容了
            2.以后数据改变不会引起v-once所在的结构更新，可用于优化性能
     -->
    <div id="root">
        <h2 v-once>初始n为:{{n}}</h2>
        <h2>current:{{n}}</h2>
        <button @click="n++">点我n+1</button>
    </div>

    <script>
        Vue.config.productionTip = false;
        new Vue({
            el: "#root",
            data() {
                return {
                    n: 1
                }
            },
        })
    </script>

</body>

</html>